package day09_modi.demo14_Peptides;

public class Person {
    public Animal getAnimal() {
        return animal;
    }

    public Person() {
    }

    public Person(Animal animal) {
        this.animal = animal;
    }

    public void setAnimal(Animal animal) {
        this.animal = animal;
    }

    private Animal animal;
    public void feed(){
        animal.eat();//每次喂食饱食度+20 健康值-10
        animal.setSum(animal.getSum()+20);
        animal.setHealth(animal.getHealth()-10);
    }
    public void playing(){
        if (animal instanceof Cat){
            Cat cat=(Cat)animal;
            cat.play();
        }else{
            Dog dog=(Dog)animal;
            dog.play();
        }//每次陪玩健康值+20 饱食度-10
        animal.setHealth(animal.getHealth()+20);
        animal.setSum(animal.getSum()-10);
    }
}
